package com.demo.controller;


import com.demo.domain.CtFarm;
import com.demo.service.impl.CtFarmServiceImpl;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * (CtFarm)表控制层
 *
 * @author makejava
 * @since 2021-07-07 09:39:48
 */
@RestController
public class CtFarmController {
    /**
     * 服务对象
     */
    @Resource
    private CtFarmServiceImpl ctFarmService;

    /**
     * 通过主键查询单条数据
     *
     * @param id 主键
     * @return 单条数据
     */
    @GetMapping("selectOne3")
    public CtFarm selectOne(Integer id) {
        return this.ctFarmService.queryById(id);
    }
    @GetMapping("selectAll3")
    public List<CtFarm> selectAll(){
        return this.ctFarmService.queryAllByLimit();
    }
    @GetMapping("insertById3")
    public CtFarm insertById(String title,String banner_images,String content,String person_name,String person_mobile){
        CtFarm ctFarm = new CtFarm();
        ctFarm.setFTitle(title);
        ctFarm.setFContent(content);
        ctFarm.setFPerson(person_name);
        ctFarm.setFPhone(person_mobile);
        ctFarm.setFImg(banner_images);

        return this.ctFarmService.insert(ctFarm);
    }
    @PostMapping("updateById3")
    public CtFarm updateById(CtFarm ctFarm){
        return this.ctFarmService.update(ctFarm);
    }
    @PostMapping("deleteById3/{id}")
    public boolean deleteById(@PathVariable int id){
        return this.ctFarmService.deleteById(id);
    }
}